package com.sgb.jicai.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.jicai.base.JiCaiBaseApi;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.jicai.view.fragment.JiCaiEnterpriseSpecialFragment;
import com.swgk.core.base.model.entity.BaseEntity;
import java.util.List;

/**
 * Time:2021/6/1
 * AUTHOR:F_Q
 * Description:
 */
public class JiCaiEnterpriseSpecialModel extends ViewModel {

    JiCaiEnterpriseSpecialFragment fragment;
    //集采分类
    public void groupBuyClassList() {
        JiCaiBaseApi.getApi().groupBuyClassList().enqueue(new ICallBack<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<PickSelectEntity>> data) {
                if (data == null || data.getState() == null) {
                    fragment.showEmptyView();
                    return;
                }

                if (data.getState().equals(JiCaiBaseApi.RESPONSE_OK)) {
                    fragment.updateSecondTabData(data.getData());
                } else {
                    fragment.showEmptyView();
                }
            }

        });
    }

    public void setActivity(JiCaiEnterpriseSpecialFragment jiCaiEnterpriseSpecialFragment) {
        this.fragment = jiCaiEnterpriseSpecialFragment;
    }
}
